package com.learn.algorithm_1;

/**
 * https://leetcode-cn.com/problems/guess-numbers/
 */
public class GuessNum {

    /**
     * 输入：guess = [1,2,3], answer = [1,2,3]
     * 输出：3
     * 解释：小A 每次都猜对了。
     */
    public static void main(String[] args) {
        int[] guess = {1,2,3};
        int[] answer = {1,2,3};
        System.out.println(guessHit(guess, answer));
    }

    private static int guessHit(int[] guess, int[] answer) {
        int length1 = guess.length;
        int length2 = answer.length;
        int min = Math.min(length1, length2);

        int count = 0;
        for (int i = 0; i < min; i++) {
            if (guess[i] == answer[i]) {
                count++;
            }
        }

        return count;
    }

}
